<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>皖西学院聘期考核与分级聘任业绩成果申报系统|登录</title>
  <link rel="stylesheet" href="${root}/static/layui/css/layui.css" media="all">
  <style>
    .login-box {
      margin: 145px auto 0;
      width: 320px;
      padding: 10px;
    }

    .login-box .login-title {
      font-weight: bold;
      font-size: 18px;
      text-align: center;
    }

    #imgCode {
      position: relative;
    }
    #imgCode img {
      position: absolute;
      top: 1px;
      right: 1px;
      cursor: pointer;
      height: 36px;
    }
  </style>
  <#include 'gio.ftl'>
</head>
<body class="layui-bg-gray">
<div class="login-box">
  <div class="layui-card">
    <div class="layui-card-header">
      <h4 class="login-title">系统登录</h4>
    </div>
    <div class="layui-card-body">
      <form class="layui-form"> <!-- 提示：如果你不想用form，你可以换成div等任何一个普通元素 -->
        <div class="layui-form-item">
          <input name="username" placeholder="账号/工号" maxlength="10" class="layui-input" lay-verify="required" lay-verType="tips">
        </div>
        <div class="layui-form-item">
          <input name="password" type="password" placeholder="用户密码" class="layui-input" lay-verify="required" lay-verType="tips">
        </div>
        <div class="layui-form-item input-item" id="imgCode">
          <input placeholder="请输入验证码" name="code" class="layui-input" lay-verify="required" lay-verType="tips">
          <img src="${root}/verify">
        </div>
        <div class="layui-form-item">
          <button class="layui-btn layui-btn-fluid" lay-submit>登 录</button>
        </div>
      </form>
      <div style="margin-top: -5px;">
        <a href="${root}/register" class="layui-word-aux">我要注册</a>
      </div>
    </div>
  </div>
</div>
<script src="${root}/static/layui/layui.js"></script>
<script>
  var loginIndex = 0;
  layui.use(['form', 'jquery', 'layer'], function(){
    var form = layui.form;
    var $ = layui.$;
    var layer = layui.layer;

    form.on('submit', function (obj) {
      if (loginIndex > 0) {
        layer.close(loginIndex);
        loginIndex = 0;
        return false;
      }
      var lidx = layer.load();
      var vals = obj.field;

      $.post('${root}/user/none/login', vals, function (data) {
        layer.close(lidx);
        if (data.status === 200) {
          loginIndex = layer.msg("登录成功！", {icon: 6, time: 1200});
          setTimeout(function () {
            location.href = "${root}/home";
          }, 1250);
        } else {
          loginIndex = layer.alert(data.message, {icon: 2, title: '错误', end: function () {
              if (loginIndex > 0) loginIndex = 0;
            }});
        }
      });
      return false;
    });

    $('#imgCode img').click(function () {
      var suf = (Math.random() * 100).toFixed();
      this.src = "${root}/verify?" + suf;
    });
  });
</script>
</body>
</html>